package pushlog

import (
	"fmt"

	"github.com/gogf/gf/frame/g"
)

type PushTitle = string

// 机器人公共配置
const (
	// 自定义消息类型
	ErrLogTitle PushTitle = "【大佬们 (%s) %s 惊现ERR】"
	MsgTitle    PushTitle = "【普通消息】"
)

// 钉钉配置
const (
	// 文本 (text)、链接 (link)、markdown(markdown)、ActionCard、FeedCard
	TextForReq       = "text"
	MarkdownForReq   = "markdown"
	LinkForReq       = "link"
	ActionCardForReq = "ActionCard"
	FeedCardForReq   = "FeedCard"
)

var (
	DefaultCjEmail    *EmailPush
	DefaultCjDingDing *DingDing
)

func init() {
	// 初始化话发生对象
	DefaultCjEmail = NewEmailPush()
	DefaultCjDingDing = NewDingDing(5, g.Cfg().GetString("dingding.push_dingding_url"))
}

// GetPushLogTitle 获取推送的日志的标题
func GetPushLogTitle(projectName, appName string) (title string) {
	envName := "prd"
	if g.Cfg().GetBool("business.is_test") {
		envName = "dev"
	}
	return fmt.Sprintf(ErrLogTitle, envName, projectName+"/"+appName)
}
